package com.example.mybatis.controller;


import com.example.mybatis.entity.User;
import com.example.mybatis.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Amu
 * @since 2022-02-08
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/insert")
    public String insert(){
        User user = new User();
        user.setId(0L);
        user.setName("jay");
        user.setAge(0);
        user.setEmail("888@qq.com");
        userService.save(user);
        return user.toString();
    }

    @RequestMapping("/findAll")
    public List<User> findAll(){
        return userService.list();
    }


    @RequestMapping("/dynamicTableName")
    public List<User> dynamicTableName(){
        return userService.dynamicTable();
    }
}
